package com.hyl.jspdemo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @Description TODO
 * @Author hyl
 * @Date 2022/5/31 14:28
 **/
@Controller
public class LoginController {


	@RequestMapping(value = "/tologin")
	public String tologin(){
		System.out.println("Controller");
		return "login";
	}

	@RequestMapping(value = "/login/{name}/{pwd}") //restful
	public String login(@PathVariable String name,
	                    @PathVariable String pwd, HttpSession session){
		System.out.println("get:"+name+" "+pwd);
		session.setAttribute("loginuser", name);
		return "login"; //json
	}

	@PostMapping(value = "/reg")
	public String regist(String name,String pwd){
		System.out.println(name+" "+pwd);
		return "reg";
	}
}
